import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:meiyunapp/router/routers_pages.dart';
import 'package:meiyunapp/service/store_services.dart';

class LoginMiddleware extends GetMiddleware {
  int mpriority = 0;

  LoginMiddleware({required this.mpriority});

  @override
  RouteSettings? redirect(String? route) {
    var mStoreService = StoreService.to;

    var name = mStoreService.getStringValue("name");
    if (name != null) {
      Future.delayed(const Duration(seconds: 1), () => Get.snackbar("提示", "请先登录APP"));
      return const RouteSettings(name: RouterPath.page_login);
    }
    return null;
  }
}
